/**
 * @param {number[]} nums
 * @return {number}
 */
var singleNumber = function(nums) {
  nums = nums.sort();
  for(let i = 0; i < nums.length; i++) {
    if(nums[i] != nums[i + 1])
      return nums[i];
    else
      i++;
  }
};

let nums = [2,2,1];
console.log(singleNumber(nums));
nums = [4,1,2,1,2];
console.log(singleNumber(nums));
